/*
 * Will Dignazio (C) 2014
 * control.c
 */
#include <Python.h>
#include <pyepiphany.h>
#include <e-hal.h>

/* 
 * Initialize HAL data structures, establish connection
 * to the Epiphany platform.
 */
PyObject*
epiphany_init(PyObject *self, PyObject *args)
{
	char *hdf_path;
	int ret;

	/*
	 * If the path is not given in the arguments
	 * we'll take the default one in the /opt dir.
	 */
	hdf_path = DEFAULT_HDF_PATH;

	if(!PyArg_ParseTuple(args, "|s", &hdf_path))
		return NULL;

	ret = e_init(hdf_path);
	return Py_BuildValue("i", ret);
}

/*
 * Finalize connection with Epiphany system, resources
 * allocated in e_init are freed.
 */
PyObject*
epiphany_finalize(PyObject *self, PyObject *args)
{ 
	int ret;

	ret = e_finalize();
	return Py_BuildValue("i", ret);
}
